﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
using libMasterSetup.Images.SalesTermsAndTrade;

namespace libMasterSetup.Forms.Billing
{
    public partial class frmSalesAndTrade : Telerik.WinControls.UI.RadForm
    {
        private int intX;
        private int intY;

        public frmSalesAndTrade()
        {
            InitializeComponent();
        }

        ~frmSalesAndTrade()
        { }

        private void frmSalesAndTrade_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            this.ControlBox = false;
            this.MinimizeBox = false;
            this.MaximizeBox = false;
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }

        public void setPoint(int X, int Y)
        {
            intX = X;
            intY = Y;
        }

        //private void dgvTermsAndCharges_CommandCellClick(object sender, EventArgs e)
        //{
        //  //  GridCellElement cellElement = this.dgvTermsAndCharges.TableElement.GetCellElement(this.dgvTermsAndCharges.CurrentRow, this.dgvTermsAndCharges.CurrentColumn);
            
        //    //if (cellElement != null)
        //    //{
        //    //    Point cellLocation = this.dgvTermsAndCharges.PointToScreen(cellElement.ControlBoundingRectangle.Location);

        //    //    if (cellElement.ColumnInfo.Name   == "gvccFixCharges")
        //    //    {
        //    //        frmFixcharges x = new frmFixcharges(cellLocation.X, cellLocation.Y + dgvTermsAndCharges.CurrentCell.Size.Height);
        //    //        x.ShowDialog(); 
        //    //    }

        //   //     GridCellElement cellElement = this.dgvTermsAndCharges.TableElement.GetCellElement(this.dgvTermsAndCharges.CurrentRow, this.dgvTermsAndCharges.CurrentColumn);

        //   //     if (cellElement != null)
        //   //     {
        //   //         Point cellLocation = this.dgvTermsAndCharges.PointToScreen(cellElement.ControlBoundingRectangle.Location);
        //   //         if (cellElement.ColumnInfo.Name == "gvccFixCharges")
        //   //         {
        //   //             frmFixcharges x = new frmFixcharges();

        //   //           //  x.setPoint(cellLocation.X, cellLocation.Y + dgvTermsAndCharges.CurrentCell.Size.Height);
        //   //             x.set_Title("Test title 1");
        //   //             x.ShowDialog();
        //   //         }
        //   //         if (cellElement.ColumnInfo.Name == "gvccOptionalCharges")
        //   //         {
        //   //             frmOptionalServices x = new frmOptionalServices();
        //   //             x.set_Title("Test title 2");
        //   //           //  x.setPoint(cellLocation.X, cellLocation.Y + dgvTermsAndCharges.CurrentCell.Size.Height);
        //   //             x.ShowDialog();
        //   //         }
        //   //     }
        //   //// }
        //}

        private void btnOk_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void dgvTermsAndCharges_CommandCellClick(object sender, EventArgs e)
        {
            GridCellElement cellElement = this.dgvTermsAndCharges.TableElement.GetCellElement(this.dgvTermsAndCharges.CurrentRow, this.dgvTermsAndCharges.CurrentColumn);

            if (cellElement != null)
            {
                Point cellLocation = this.dgvTermsAndCharges.PointToScreen(cellElement.ControlBoundingRectangle.Location);
                if (cellElement.ColumnInfo.Name == "gvccFixCharges")
                {
                    frmFindFixcharges x = new frmFindFixcharges();

                    //  x.setPoint(cellLocation.X, cellLocation.Y + dgvTermsAndCharges.CurrentCell.Size.Height);
                    x.set_Title("Test title 1");
                    x.ShowDialog();
                }
                if (cellElement.ColumnInfo.Name == "gvccOptionalCharges")
                {
                    frmFindOptionalServices x = new frmFindOptionalServices();
                    x.set_Title("Test title 2");
                    //  x.setPoint(cellLocation.X, cellLocation.Y + dgvTermsAndCharges.CurrentCell.Size.Height);
                    x.ShowDialog();
                }
            }
            // }
        }

        private void radGroupBox2_Click(object sender, EventArgs e)
        {

        }

        private void radButton1_Click(object sender, EventArgs e)
        {
            frmFindFixcharges x = new frmFindFixcharges();
            x.ShowDialog();
        }

        private void radButton2_Click(object sender, EventArgs e)
        {
            frmFindOptionalServices x = new frmFindOptionalServices();
            x.ShowDialog();
        }

        private void frmSalesAndTrade_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose();
            GC.Collect();
            GC.WaitForFullGCComplete();
            GC.Collect();
        }
    }
}
